package com.huawei.appgallery.forum.cards.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import o.bsy.i;

public class ForumRoundCornerLayout extends RelativeLayout {
    private Paint ʽ;
    private float ˊ;
    private float ˋ;
    private float ˎ;
    private Paint ˏ;
    private float ॱ;

    public ForumRoundCornerLayout(Context context) {
        this(context, null);
    }

    public ForumRoundCornerLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public ForumRoundCornerLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, i.ـ);
            float dimension = obtainStyledAttributes.getDimension(i.ॱʻ, 0.0f);
            this.ˊ = obtainStyledAttributes.getDimension(i.ॱʽ, dimension);
            this.ॱ = obtainStyledAttributes.getDimension(i.ॱͺ, dimension);
            this.ˎ = obtainStyledAttributes.getDimension(i.ॱʼ, dimension);
            this.ˋ = obtainStyledAttributes.getDimension(i.ᐝᐝ, dimension);
            obtainStyledAttributes.recycle();
        }
        this.ˏ = new Paint();
        this.ˏ.setColor(-1);
        this.ˏ.setAntiAlias(true);
        this.ˏ.setStyle(Style.FILL);
        this.ˏ.setXfermode(new PorterDuffXfermode(Mode.DST_OUT));
        this.ʽ = new Paint();
        this.ʽ.setXfermode(null);
    }

    protected void dispatchDraw(Canvas canvas) {
        canvas.saveLayer(new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), this.ʽ, 31);
        super.dispatchDraw(canvas);
        ˊ(canvas);
        ˎ(canvas);
        ˋ(canvas);
        ˏ(canvas);
        canvas.restore();
    }

    private void ˊ(Canvas canvas) {
        if (this.ˊ > 0.0f) {
            Path path = new Path();
            path.moveTo(0.0f, this.ˊ);
            path.lineTo(0.0f, 0.0f);
            path.lineTo(this.ˊ, 0.0f);
            path.arcTo(new RectF(0.0f, 0.0f, this.ˊ * 2.0f, this.ˊ * 2.0f), -90.0f, -90.0f);
            path.close();
            canvas.drawPath(path, this.ˏ);
        }
    }

    private void ˎ(Canvas canvas) {
        if (this.ॱ > 0.0f) {
            int width = getWidth();
            Path path = new Path();
            path.moveTo(((float) width) - this.ॱ, 0.0f);
            path.lineTo((float) width, 0.0f);
            path.lineTo((float) width, this.ॱ);
            path.arcTo(new RectF(((float) width) - (this.ॱ * 2.0f), 0.0f, (float) width, this.ॱ * 2.0f), 0.0f, -90.0f);
            path.close();
            canvas.drawPath(path, this.ˏ);
        }
    }

    private void ˋ(Canvas canvas) {
        if (this.ˎ > 0.0f) {
            int height = getHeight();
            Path path = new Path();
            path.moveTo(0.0f, ((float) height) - this.ˎ);
            path.lineTo(0.0f, (float) height);
            path.lineTo(this.ˎ, (float) height);
            path.arcTo(new RectF(0.0f, ((float) height) - (this.ˎ * 2.0f), this.ˎ * 2.0f, (float) height), 90.0f, 90.0f);
            path.close();
            canvas.drawPath(path, this.ˏ);
        }
    }

    private void ˏ(Canvas canvas) {
        if (this.ˋ > 0.0f) {
            int height = getHeight();
            int width = getWidth();
            Path path = new Path();
            path.moveTo(((float) width) - this.ˋ, (float) height);
            path.lineTo((float) width, (float) height);
            path.lineTo((float) width, ((float) height) - this.ˋ);
            path.arcTo(new RectF(((float) width) - (this.ˋ * 2.0f), ((float) height) - (this.ˋ * 2.0f), (float) width, (float) height), 0.0f, 90.0f);
            path.close();
            canvas.drawPath(path, this.ˏ);
        }
    }
}
